
package com.catsic.zcjc.specifiction;

import javax.persistence.criteria.Path;

import com.catsic.base.specification.BaseSpec;
import com.catsic.base.specification.QueryWraper;
import com.catsic.zcjc.condition.SystemCondition;
import com.catsic.zcjc.entity.System;

public class SystemSpec extends BaseSpec<System> {

	public SystemSpec(SystemCondition condition){
		super(condition);
	}
	

	@Override
	protected void addCondition(QueryWraper<System> queryWraper) {
		SystemCondition condition = (SystemCondition) getCondition();
		addLikeCondition(queryWraper, "name");
		this.addEqualCondition(queryWraper, "type");
		
		/**
		 * 多表联查,多对一,机构
		 */
		Path<System> station = queryWraper.getRoot().get("station");
		addEqualCondition(queryWraper, station.get("id"),condition.getStationId());
		
	
		/**
		 * 自定义排序
		 */
		queryWraper.addOrder(queryWraper.getCb().asc(queryWraper.getRoot().get("code")));
	    
		
	}
}
